<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品表列表</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <#include "/view/admin/head.html"/>
    <script type="text/javascript" src="${base}/jstool/bootstrap-switch/bootstrap-switch.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-switch/bootstrap-switch.min.css" />
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />

    <script type="text/javascript" src="${base}/jstool/bootstrap-select/js/bootstrap-select.min.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-select/lang/defaults-zh_CN.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-select/css/bootstrap-select.min.css" />

    <style type="text/css">
        .table-class{
            width:90%;
            text-align: center;
            border:1px solid #afd9ee;
            margin:0 auto;
            margin-top: 50px;
        }
        .list-path{
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;

        }
        table th{
            text-align: center;
            WORD-WRAP: break-word;
            width: 100px;
        }
        table thead tr {
            background-color: #9acfea;
        }
        .table-query{
            /*height: 40px;*/
            /*width:80px;*/
            /*text-align: center;*/
            white-space:nowrap;
            /*position: relative;*/
            float: left;
            display:inherit;
            /*display: inline;*/


        }
        .label-head{
            height: 60px;
            width: 100%;
        }
        .bs-example .input-group{
            width:300px;
            float: left;
            margin-top:20px;

        }
        .bank-label{
            width:25px;
            float: left;
        }
        .label-hidden{
            display: none;
        }
        .panel-body{
            padding-top: 0px;
        }
        .input-group input[type='text']{
            z-index: inherit;
        }
       /* .input-group{
            margin-top:20px;
        }*/
    </style>
   
  <!--   <script src="${base}/jstool/artDialog/lib/sea.js"></script>
    
       <script>
        seajs.config({
            alias: {
                "jquery": "${base}/jstool/artDialog/lib/jquery-1.10.2.js"
            }
        });
    </script>
    
    <script>
        seajs.use(['jquery', '${base}/jstool/artDialog/src/dialog.js'], function ($, dialog) {


            //关联用户
            $('button[data-event=adduser]').on('click', function () {
                this.disabled="disabled";
                var commodityId = $(this).attr('id').substring(2);
                var myDialog = dialog({
//                    follow:this,
                    fixed: true,
                    lock: true,
                    okValue: '确 定',
                    ok: function () {

                        setcode();
                        $('#a_'+commodityId).removeAttr("disabled");
                        return true;
                    },
                    cancelValue: '取消',
                    cancel: function () {
                        $('#a_'+commodityId).removeAttr("disabled");
                    }
//                    cancelValue: '取消'
//                    follow: document.getElementById('followTestBtn'),
                });// 初始化一个带有loading图标的空对话框

                jQuery.ajax({
                    url: '${base}/busin/getAwardstockByBusin?commodityId='+commodityId,
                    success: function (data) {

//                        alert(1);
//                        myDialog.title('');
                        myDialog.content(data);// 填充对话框内容
//                        myDialog.lock();
//                        myDialog.__follow(this);
                       /* myDialog.button({
                            name: '登录',
                            focus: true,
                            callback: function () {}
                        }, {
                            name: '取消',
                            callback: function () {alert('取消');myDialog.close();}
                        })*/
                        myDialog.show();
                    }
                });
            });
                //角色授权
                $('button[data-event=updatepermission]').on('click', function () {
                	alert();
                this.disabled="disabled";
                var roleId = $(this).attr('id').substring(2);
                var myDialog = dialog({
//                    follow:this,
                    fixed: true,
                    lock: true,
//                    background:'#000',
                    okValue: '确 定',
                    ok: function () {

                        setcode();
                        $('#p_'+roleId).removeAttr("disabled");
                        return true;
                    },
                    cancelValue: '取消',
                    cancel: function () {
                        $('#p_'+roleId).removeAttr("disabled");
                    }
                });// 初始化一个带有loading图标的空对话框

                jQuery.ajax({
                    url: '${base}/xypermission/updatepermission.do?roleId='+roleId,
                    success: function (data) {
                        myDialog.content(data);// 填充对话框内容
                        myDialog.show();
                    }
                });
            });


        });
    </script> -->
    
    <script type="text/javascript">
        function query(dm){
            var href = "${base}/busin/list?";

            href+='businessId='+$('#businessId').val();
                    href+='&'

            href+='commodityName='+$('#commodityName').val();
                    href+='&'

            href+='typeId='+$('#typeId').val();
                    href+='&'




            href+='content='+$('#content').val();
                    href+='&'


            href+='soldOut='+$('#soldOut').val();
                    href+='&'

            href+='approveStatus='+$('#approveStatus').val();
                    href+='&'

            href+='approveTimeStart='+$('#approveTimeStart').val()+"&";
            href+='approveTimeEnd='+$('#approveTimeEnd').val();
                    href+='&'

            href+='createTimeStart='+$('#createTimeStart').val()+"&";
            href+='createTimeEnd='+$('#createTimeEnd').val();
                    href+='&'


            location.href=href;
        }
        $(function() {
            //初始化
       /*          $('#approveTimeStart').datetimepicker();
                $('#approveTimeEnd').datetimepicker();
                $('#createTimeStart').datetimepicker();
                $('#createTimeEnd').datetimepicker(); */
                $('#approveTimeStart').datetimepicker({

                	　　language: 'zh-CN',
                	　　autoclose: true,
                	　　todayHighlight: true
                	});
                $('#approveTimeEnd').datetimepicker({

              	　　language: 'zh-CN',
              	　　autoclose: true,
              	　　todayHighlight: true
              	});
                $('#createTimeStart').datetimepicker({

              	　　language: 'zh-CN',
              	　　autoclose: true,
              	　　todayHighlight: true
              	});
                $('#createTimeEnd').datetimepicker({

              	　　language: 'zh-CN',
              	　　autoclose: true,
              	　　todayHighlight: true
              	});
        });
    </script>
    
    <script>
    	
    function theShelves(){
    	
    	if(window.confirm("您确定上架吗？")){
    		
    		window.location="";
    	}
    	
    }
    
 function offShelves("您确定下架吗？"){
    	
	 window.location="";
    }
    
    
    </script>
</head>
<body>

	<#include "/view/admin/listnav.html"/> 

<div class="table-class ">
    <div class="panel panel-default" style="margin: 10px 50px 10px;">
     <div class="panel-body">
       <form class="bs-example bs-example-form" role="form">

                <div class="input-group">
                
                    <span class="input-group-addon">是否下架</span>
                    <select id="soldOut" name="soldOut" class="form-control" >
                       <  <option value="">请选择是否下架</option>
                                    <option value="1" <#if soldOut??&&1 == soldOut>selected="selected"</#if>>是</option>
                                    <option value="0" <#if soldOut??&&0 == soldOut>selected="selected"</#if>>否</option>
                    </select>
                </div>
                <span class="bank-label">&nbsp;</span>


                <div class="input-group">
                    <span class="input-group-addon">商品名称</span>
                    <input type="text" id="commodityName" class="form-control" value="${commodityName!}" name="commodityName" >
                
                </div>
                  <span class="bank-label">&nbsp;</span>
                  <div class="input-group">
                    <span class="input-group-addon">创建时间>=</span>
                  <!--   <input type="text" id="createTimeStart" class="form-control" value="<#if (createtime)?? >${createtime?string('yyyy-MM-dd HH:mm:ss')}</#if>" name="createTimeStart"  data-date-format="yyyy-mm-dd hh:ii:ss"> -->
                	  <input type="text" id="createTimeStart" class="form-control" value="<#if (createTimeStart)?? >${createTimeStart?string('yyyy-MM-dd HH:mm:ss')}</#if>" id="createTimeStart" name="createTimeStart" data-date-format="yyyy-mm-dd hh:ii:ss">
                	
                </div>
                
            <div class="input-group" style="text-align: right;">
                <a class="btn btn-info"  href="javascript:query(this)"><span class="glyphicon glyphicon-search"></span> 查找</a>

            </div>
        </form>
     </div>
    </div>

<#include "/view/admin/opermsg.html"/>


    <table class="table table-hover table-bordered">
        <thead>
        
          <tr>
            <td colspan="11" style="background-color: white;">
                <div style="text-align:left;margin-left: 50px;">
                 <@shiro.hasPermission name="13.1.4"> 
                    <a href="${base}/busin/add" class="btn btn-primary">新增</a>
                </@shiro.hasPermission>
                </div>
            </td>
        </tr>
        
        <tr>
            <th>序号</th>
                <th class="label-hidden">主键</th>
                <th>商家</th>
             <th>商品名称</th>
                   <!-- <th>商品类型</th> -->
                <th>现价(元)</th>
                <th>原价(元)</th>
               <th>已售量</th>
               <!--  <th>内容</th> -->
               <!-- <th>获赞数</th>
                <th>差评数</th>
                <th>中评数</th>
                <th>好评数</th>
                <th>总评论数</th>-->
                <th>是否下架</th>
                <#--<th>审批状态</th>
                <th>审批时间</th>-->
                <th>创建时间</th>
                <th class="label-hidden">删除标识</th>

            <th style="width: 30%">操作</th>
        </tr>
        </thead>
        <tbody>
        <#list pagination.list as c>
            <tr>
                <td>${(pagination.pageNo-1)*pagination.pageSize+1+c_index}</td>
                        <td class="label-hidden">${c.id!}</td>
                        <td> 
                            <#if c.businessId??>
                                    <#list listBusinessId as lv>
                                        <#if lv.value??&&c.businessId == lv.value >
                                        ${lv.name!}
                                        </#if>
                                    </#list>

                            </#if>


                        </td>
                            <td>${c.commodityName!}</td>

                      <!--   <td> 

                            <#if c.typeId??>
                                    <#list listTypeId as lv>
                                        <#if lv.value??&&c.typeId == lv.value >
                                        ${lv.name!}
                                        </#if>
                                    </#list>

                            </#if>

                        </td> -->
                            <td>${c.presentPrice?default(0)}</td>

                            <td>${c.originalPrice?default(0)}</td>

                            <td>${c.soldCount?default(0)}</td>

                           <!--  <td>${c.content!}</td> -->

                          <#--  <td>${c.praiseCount!}</td>

                            <td>${c.badCount!}</td>

                            <td>${c.middleCount!}</td>

                            <td>${c.highCount!}</td>

                            <td>${c.allCount!}</td>-->

                    <td> 
                            <#if c.soldOut??>

                         <#if 1==c.soldOut><span class="label label-success">是</span></#if>

                         <#if 0==c.soldOut><span class="label label-default">否</span></#if>
                            </#if>
                    </td>
                    <!--    <td>


                            <#if c.approveStatus??>
                                        <#if 0==c.approveStatus><span class="label label-default">审批中</span>

                                        <#elseif   1==c.approveStatus><span class="label label-success">审批通过</span>

                                        <#elseif 2==c.approveStatus><span class="label label-danger">审批不通过</span>

                                    </#if>

                            </#if>
                        </td>
                        <td><#if c.approveTime?? >${c.approveTime?string('yyyy-MM-dd HH:mm:ss')}</#if></td>-->
                        <td><#if c.createTime?? >${c.createTime?string('yyyy-MM-dd HH:mm:ss')}</#if></td>
                        <td class="label-hidden">${c.delFlag!}</td>

                <td>
             
                <@shiro.hasPermission name="13.1.2">     
                    <a href="${base}/busin/add.do?id=${c.id!}" class="btn btn-primary">修改</a>
                </@shiro.hasPermission>   
                <!--  <@shiro.hasPermission name="13.1.5">     
                  <button data-event="adduser" id="a_${c.id!}"  class="btn btn-primary">优惠券</button>
                   </@shiro.hasPermission> -->
                
				    <@shiro.hasPermission name="13.1.1"> 
                    <a href="${base}/busin/detail.do?id=${c.id!}" class="btn btn-primary">预览</a>
                </@shiro.hasPermission>   
                
                 <@shiro.hasPermission name="13.1.5"> 
				<#if c.soldOut ?? &&  c.soldOut==0>
					<a href="javascript:if(confirm('您确定要下架吗?'))location=('${base}/busin/shelves?commodityId=${c.id!}&pageNo=${pagination.pageNo}&pageSize=${pagination.pageSize}&soldOut=1')" class="btn btn-danger">下架</a>
					<#else>
						 <a href="javascript:if(confirm('您确定要上架吗?'))location=('${base}/busin/shelves?commodityId=${c.id!}&pageNo=${pagination.pageNo}&pageSize=${pagination.pageSize}&soldOut=0')" class="btn btn-primary">上架</a>
				</#if>
				</@shiro.hasPermission>
				
				
        <@shiro.hasPermission name="13.1.3">    
                    <a href="javascript:checkDelete('${base}/busin/delete.do?id=${c.id!}')" class="btn btn-primary">删除</a>
                </@shiro.hasPermission>
    
                </td>
            </tr>


        </#list>
        <#if 0==pagination.totalCount>
            <tr>
                <td colspan="7" style="color: red"> 没有相关数据 </td>
            </tr>
        </#if>
        <!-- <tr>
            <td colspan="11">
                <div style="text-align:left;margin-left: 50px;">
                 <@shiro.hasPermission name="13.1.4"> 
                    <a href="${base}/busin/add" class="btn btn-primary">新增</a>
                </@shiro.hasPermission>
                </div>
            </td>
        </tr> -->





        </tbody>
    </table>
        <!--<span style="text-align: left"> <a href="#" class="btn btn-primary">新增</a></span>-->
    <#include "/view/admin/pagination.html"/>


</div>
<script>
    function setPage(pageNo,pageSize){
        var href = "${base}/busin/list?";


            href+='commodityName='+$('#commodityName').val()+"&";





            href+='content='+$('#content').val()+"&";






            href+='soldOut='+$('#soldOut').val()+"&";


            href+='approveTimeStart='+$('#approveTimeStart').val()+"&";
            href+='approveTimeEnd='+$('#approveTimeEnd').val()+"&";

            href+='createTimeStart='+$('#createTimeStart').val()+"&";
            href+='createTimeEnd='+$('#createTimeEnd').val()+"&";


        href+="&pageNo="+pageNo;
        href+="&pageSize="+pageSize;
        location.href=href;
    }
    function checkDelete(url){
        if (window.confirm("确认删除吗?")) {
            location.href=url;
        }
    }

</script>

</body>
</html>
